package com.project.controller;

import com.project.bean.ProductBean;

import com.project.bean.SpeakBean;
import com.project.bean.UserBean;
import com.project.service.ISpeakService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("speak")
public class SpeakController {
    @Autowired
    private ISpeakService service;

    @RequestMapping("add")
    public String add(int productId, String  content, HttpServletRequest request){
        //从session得到登录用户
        UserBean userBean = (UserBean)request.getSession().getAttribute("loginUser");
        SpeakBean speakBean = new SpeakBean(userBean.getId(),productId,content);
        service.add(speakBean);
        return "ok";
    }
}
